#include "lib/pvmstrings.h"
#include <string.h>
#include <wchar.h>

#include "lib/memory/pvmmemory.h"

pvm_size pvm_strlen(const pvm_char* str)
{
  return wcslen((const wchar_t*)str);
}

pvm_size pvm_strcmp(const pvm_char* str1, const pvm_char* str2)
{
  return wcscmp((const wchar_t*)str1, (const wchar_t*)str2);
}

pvm_size pvm_strncmp(const pvm_char* str1, const pvm_char* str2, pvm_size count)
{
	for(pvm_size i=0; i<count; i++)
	{
		if(str1[i]==0)
			return -i;
		if(str2[i]==0)
			return i;
		
		if(str1[i]!=str2[i])
			return str1[i] - str2[i];
	}
	return 0;
}

pvm_char* pvm_strcpy(pvm_char* strDst, const pvm_char* strSrc)
{
  return (pvm_char*)wcscpy((wchar_t*)strDst, (const wchar_t*)strSrc);
}

pvm_char* pvm_strcat(pvm_char* strDst, const pvm_char* strSrc)
{
  return (pvm_char*)wcscat((wchar_t*)strDst, (const wchar_t*)strSrc);
}
